import { del, get, post, put } from './request'

// 注册
export const register = (data) => {
  return post('/api/v1/users', data)
}

// 登录
export const login = (data) => {
  return post('/api/v1/users/login', data)
}

// 退出登录
export const logout = (data) => {
  return post('/api/v1/users/logout', data)
}

// 删除用户
export const delUser = (id) => {
  return del(`/api/v1/users/${id}`)
}

// 更新用户
export const updateUser = (id, data) => {
  return put(`/api/v1/users/${id}`, data)
}

// 重置密码
export const resetPassword = (id) => {
  return put(`/api/v1/users/${id}/password`)
}

// 查询所有用户
export const findUser = (params) => {
  return get('/api/v1/users', params)
}

// 查询单个用户信息
export const findUserInfo = (id) => {
  return get(`/api/v1/users/${id}`)
}

// 用户名是否存在
export const checkUsernameExists = (username) => {
  return get(`/api/v1/users/name/${username}/exists`)
}
